package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * JDBC Java DataBase Connectivity
 */
public class JDBCDemo1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {

        Class.forName("com.mysql.cj.jdbc.Driver");

        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://10.172.23.77:23307/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "123456TCP"
        );
        System.out.println("与数据库建立连接！");

        Statement statement = connection.createStatement();

        String sql = "create table userinfo " +
                "( " +
                "    id       int primary key auto_increment, " +
                "    username varchar(32), " +
                "    password varchar(32), " +
                "    nickname varchar(32), " +
                "    age      int(3) " +
                ")";
        statement.execute(sql);
        System.out.println("表创建成功！");

        connection.close();



    }
}
